<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <script>
        //将字符串转换为数值
        console.log(Number("123")); //123
        console.log(Number("123abc")); //NaN
        //将字符串转换为数值
        console.log(parseInt("123")); //123
        console.log(parseInt("123abc")); //123
        console.log(parseInt("abc123abc")); //NaN
        //将字符串转换为浮点
        console.log(parseFloat("1.23")); //1.23
        console.log(parseFloat("1.23abc")); //1.23
        console.log(parseFloat("abc1.23abc")); //NaN
    </script>
</body>
</html>